package com.crm.service.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.crm.dao.UserDao;
import com.crm.domain.User;
import com.crm.service.UserService;
import com.crm.utils.MD5Utils;
/**
 * @author Yusei
 * UserService接口的实现
 */
@Transactional
public class UserServiceImpl implements UserService {
	// 注入dao
	private UserDao userDao;
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	@Override
	// 用户登录
	public User login(User user) {
		// 先加密用户输入的密码
		user.setUser_password(MD5Utils.md5(user.getUser_password()));
		return userDao.login(user);
	}


	@Override
	// 用户注册
	public void regist(User user) {
		// 对密码进行加密
		String password = MD5Utils.md5(user.getUser_password());
		user.setUser_password(password);
		user.setUser_state("1");
		userDao.regist(user);
	}

	@Override
	// 客户拜访记录-添加客户拜访记录-查询所有客户
	public List<User> findAllUser() {
		return userDao.findAll();
	}
}
